import React, {Component} from 'react';
import './index.less';
import {base} from 'nc-lightapp-front';
import {getQueryCondition} from 'src/hrpub/common/utils/utils.js'

class SearchModal extends Component {
    constructor(props) {
        super(props);
        this.goSearch = this.goSearch.bind(this);
    }

    goSearch() {
        const {updateState, pageInfo, getMainTableData, search} = this.props;
        let data = getQueryCondition(this.props, 'query');
        updateState({
            searchModalValue: data,
            pageInfo: {
                ...pageInfo,
                pageIndex: 1
            }
        }, () => {
            getMainTableData();
            search.openAdvSearch('query', false)
        });
    }

    render() {
        return (
            <div style={{display: 'none'}}>
                {this.props.search.NCCreateSearch('query', {
                    clickSearchBtn: this.goSearch,
                    onlyShowAdvArea: false,
                    showAdvSearchPlanBtn: true,
                    saveSearchPlan: true,
                    // oid: this.props.queryOid,
                    onlyShowSuperBtn: true
                })}
            </div>
        );
    }
}

export default SearchModal;